@extends('layouts.app')
@section('header')
     @include('common.header')
@stop
@section('title', $category->seo_title)
@section('content')
<div class="banner1"></div>
<div class="xtxx">
            <div class="xtxx_top">
                <div class="xtxx_tit"><p><a href="/cart?catid=12">名片宝库</a>&nbsp;&gt;&nbsp;<a href="/cart?catid={{$category->id}}">{{$category->name}}</a></p></div>
            </div>
            <input id="pagetype" type="hidden" value="0">
            <div class="maijianav">
                <div class="mpbk_tit">
                <ul class="clearfix maijia-nav ">
                @if(isset($menu[12]) && !empty($menu[12]))
                        	@foreach($menu[12]['child'] as $k=>$row)
                        	<li class="fl {{$category->id==$row['id']?'navdown1':''}}"><a href="/cart?catid={{$row['id']}}">{{$row['name']}}</a></li>
                        @endforeach

                        @endif


                </ul>
                </div>
                <div class="content-maijia">
                    <div class=" ct">
                        <div class="mpbk_nr">
                            <div class="mpbkbox">
                                <div class="mjzh_ss">
                                    <a class="btn4 fr" href="/user/sendCart">我也要发布</a>
                                    <div class="ssnr">

                                       <form class="form-horizontal" method="get"  action="{{url($category->controller.'?catid='.$category->id)}}">
            <input class="wby4" name="catid" type="hidden" value="{{$category->id}}">
                            <input class="wby4" name="keyword" value="{{$keyword}}" type="text">
                            <input class="btn3" name="" type="submit" value="搜索">
                          </form>

                                    </div>
                                </div>
                                <div class="lbgs">
                                    <table border="0" cellpadding="0" cellspacing="0" class="bgys1" width="100%">

                                        <tbody><tr>
                                            <td bgcolor="#009ee7">
                                                <div align="center" class="STYLE1">发布时间</div>
                                            </td>
                                            <td bgcolor="#009ee7">
                                                <div align="center" class="STYLE1">公司名称</div>
                                            </td>
                                            <td bgcolor="#009ee7">
                                                <div align="center" class="STYLE1">职称</div>
                                            </td>
                                            <td bgcolor="#009ee7">
                                                <div align="center" class="STYLE1">网址</div>
                                            </td>
                                            <td bgcolor="#009ee7">
                                                <div align="center" class="STYLE1">备注（产品说明、其它介绍）</div>
                                            </td>
                                            <td bgcolor="#009ee7">
                                                <div align="center" class="STYLE1">查看</div>
                                            </td>
                                        </tr>
                                        </tbody><tbody id="tbody">
										@if($pageList->count() == 0)
										<tr><td>没有搜索到数据</td></tr>
										@else
                                        @foreach($pageList as $row)

                                        <tr ><td bgcolor="#c2ebff"><div align="center">{{$row->updated_at->toDateString()}}</div></td>
                                          <td bgcolor="#c2ebff"><div align="center">{!!str_replace($keyword,"<font color=red>{$keyword}</font>", $row->company)!!}</div></td>
                                          <td bgcolor="#c2ebff"><div align="center">{!!str_replace($keyword,"<font color=red>{$keyword}</font>", $row->fname)!!}</div></td>
										<td bgcolor="#c2ebff"><div align="center">{{$row->homepage}}</div></td>
										<td bgcolor="#c2ebff"><div align="center">{!!str_replace($keyword,"<font color=red>{$keyword}</font>", $row->content)!!}</div></td>
										<td bgcolor="#c2ebff"><div align="center">

                                        @if($row->price >0)

                                        	@guest
                                        	<a href="javascript:;" onclick="buy({{$row->id}})" class="btn5 free">购买({{$row->price}}元)</a>
                                        	@else
                                        		@if($row->buysOwn)
                                        			<a href="javascript:;" onclick="showc({{$row->id}})" class="btn5 free">查看（已购）</a>
                                            	@else
                                            		@if($row->user_id == Auth::id())
                                            		    <a href="javascript:;" onclick="showc({{$row->id}})" class="btn5 free">查看（自己）</a>

                                            		@else
                                            		     <a href="javascript:;" onclick="buy({{$row->id}})" class="btn5 free">购买({{$row->price}}元)</a>

                                            		@endif
                                            	@endif
                                        	@endguest

                                        @else

                                        <a href="javascript:;" onclick="showc({{$row->id}})" class="btn5 free">免费查看</a>
                                        @endif

                                        </a>

                                        </div></td></tr>
                                      @endforeach
									  @endif
                                        </tbody>
                                    </table>

                                </div>
<div class="dede_pages u0"><ul class="pagelist">
                                {{ $pageList->links('common.paginator', [ 'results'=>$pageList ]) }}
                                </ul></div>
                            </div>
                        </div>
                    </div>



                </div>
            </div>
        </div>
        <style>
<!--
.btn5{padding: 0 5px; width: auto;}
-->
</style>
<script type="text/javascript">
function buy(id)
{
	if(uid <=0)window.location.href='/login'

	ajaxurl('/user/buy', {item_id:id, item_type:'cart'}, function(res){
		var index = layer.open({
			  title: '信息提示'
			  ,content: res.msg,
			  yes: function(){
				if(res.status == 2){
					window.location.reload();
				}
                if(res.status == 1){
                    window.location.href = '/user/recharge';
                }
				layer.close(index);
			}
			});

	});
}
function showc(id)
{
	if(uid <=0)window.location.href='/login'

	ajaxurl('/user/showCart', {item_id:id, item_type:'cart'}, function(res){
		if(res.status == 1){
			layer.photos({
			    photos: res.data
			    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
			 });
		}else{
			layer.msg(res.msg);
		}


	});
}
</script>
@endsection
@section('footer')
     @include('common.footer')
@stop
